<!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <% include("/view/console/common/css.html"){}	%>

 <title></title>
 </head>
 <body>
 <div class="zq-form">

 <form name="wnMachineDeviceImei_form"  id="wnMachineDeviceImei_form" class="form-horizontal" style="margin-bottom: 70px;">
  <div class="form-group" >
   <label class="col-sm-2 col-xs-2 control-label">设备编号</label>
   <div class="col-sm-6 col-xs-6">
    <input  type="text"  name="deviceNumber" id="deviceNumber" class="form-control" check-type="required" value='${wnMachineDeviceImei.deviceNumber!}' >
   </div>
  </div>
   <div class="form-group">
    <label class="control-label col-sm-2 col-xs-2">所属农场</label>
    <div class="col-sm-6 col-xs-6">
     <select class="form-control" id="farmId"
             name="farmId" check-type="required">
     </select>
    </div>
   </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">购入时间</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="buyTime" placeholder="yyyy-MM-dd HH:mm:ss" id="buyTime" class="form-control" check-type="required" value='${wnMachineDeviceImei.buyTime!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">imei</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="imei" id="imei" class="form-control" check-type="required" value='${wnMachineDeviceImei.imei!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">手机号码</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="simcard" id="simcard" class="form-control" check-type="required" value='${wnMachineDeviceImei.simcard!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">有效期</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="validityPeriod" placeholder="yyyy-MM-dd HH:mm:ss" id="validityPeriod" class="form-control" check-type="required" value='${wnMachineDeviceImei.validityPeriod!}' >
 </div>
  </div>
  <input type='hidden' name='id' id='id' value='${wnMachineDeviceImei.id!}'><input type='hidden' name='common_token' id='common_token' value='${common_token!}'>
 </form>
  <nav class="navbar navbar-default navbar-fixed-bottom" style="text-align: right">
    <a href="#" class="btn btn-success" style="margin:10px"  onclick='saveZqForm()'>保存 </a>
  </nav>
 </div>
 <% include("/view/console/common/js.html"){} 	%>
 <script>

     layui.use(['layer','laydate'], function(){
         var laydate = layui.laydate;
         laydate.render({
             elem: '#validityPeriod'
             ,type: 'datetime'
         });
         laydate.render({
             elem: '#buyTime'
             ,type: 'datetime'
         });
     });
     $(function($) {
      /*开启表单验证*/
         $("#wnMachineDeviceImei_form").validation();
         //时间选择器

 /*        componentSelectInit(
             {
                 ctxPath:'',
                 tableName:"sys_dictionary",
                 showValueField:"name",
                 valueField:"value",
                 selectId:"deviceType"  ,
                 where:" where code ='device_type' "
             }
             ,function(){
                 $("#deviceType").val('${wnMachineDeviceImei.deviceType!}');
             });*/
         componentSelectInit(
             {
                 ctxPath:'',
                 tableName:"wn_farm",
                 showValueField:"name",
                 valueField:"id",
                 selectId:"farmId"  ,
                 where:""
             }
             ,function(){
                 if("${wnMachineDeviceImei.farmId!''}"!=""){
                     $("#farmId").click(function () {
                         return;
                     });
                 }
                 $("#farmId").val('${wnMachineDeviceImei.farmId!}');
             });
     });
     /*保存*/
     function saveZqForm(){
         if ($("#wnMachineDeviceImei_form").valid() == false) {
             return false;
         }
         var formObject=new Object();
         formObject.deviceType="gt06";
         formObject.farmId=$('#farmId').val()==''?null:$('#farmId').val();
         formObject.id=$('#id').val()==''?null:$('#id').val();
         formObject.buyTime=$('#buyTime').val()==''?null:$('#buyTime').val();
         formObject.imei=$('#imei').val()==''?null:$('#imei').val();
         formObject.deviceNumber=$('#deviceNumber').val()==''?null:$('#deviceNumber').val();
         formObject.simcard=$('#simcard').val()==''?null:$('#simcard').val();
         formObject.validityPeriod=$('#validityPeriod').val()==''?null:$('#validityPeriod').val();

         var formObjectJson = JSON.stringify(formObject);
         zqPost("/console/wn_machine_device_imei/save",
             {
                 formObjectJson :formObjectJson,
                 machineId:"${machineId!}",
                 common_token :$("#common_token").val()
             },
             function(data) {
                 layer.alert(data.message, {skin: 'layui-layer-molv',closeBtn: 0 }, function(){
                     parent.$("#wnMachineDeviceImei").bootstrapTable("refresh");
                     parent.layer.closeAll();
                 });

             });
     }
 </script>
 <script type='text/javascript' src='/view/console/wnMachineDeviceImei/wnMachineDeviceImeiForm.js'></script>
 </body>
